home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Michael D. Crawford↵
/
Word Services SDK 1.0.5
/
Writeswell Jr. Source
/
MyTextEdit.c
< prev
next >
Wrap
Text File
|
1993-03-08
|
1KB
|
65 lines
/* MyTextEdit.c
* Useful utility routines for TextEdit in Writeswell Jr.
* Copyright ©1993 Working Software, Inc. All Rights Reserved.
* 4 Mar 93 Mike Crawford
*/
#include "Scroll.h"
#include "MyTextEdit.h"
#include "ArrowKeyCodes.h"
void MyTEKey( WindowPtr docWindow,
ControlHandle vertScroll,
char theChar,
Boolean readOnly )
{
TEHandle textH;
short numLines;
short selStart;
Rect viewRect;
Point selPoint;
Boolean inRect;
textH = (TEHandle)GetWRefCon( docWindow );
numLines = (*textH)->nLines;
if ( readOnly ){
/* We allow the cursor keys to be entered */
switch ( theChar ){
case kLeftArrow:
case kRightArrow:
case kUpArrow:
case kDownArrow:
break;
default:
return;
}
}
TEKey( theChar, textH );
selStart = (*textH)->selStart;
viewRect = (*textH)->viewRect;
selPoint = TEGetPoint( selStart, textH );
inRect = PtInRect( selPoint, &viewRect );
if ( !inRect || numLines != (*textH)->nLines ){
/* We may need to reset the scroll bar if we changed the number of lines */
ShowSelection( textH );
SetVertScroll( docWindow, vertScroll );
}
return;
}
TEHandle GetTextHandle( WindowPtr theWindow )
{
return (TEHandle)GetWRefCon( theWindow );
}